//
//  Consume_GD_AddressTableViewCell.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/4.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Consume_GD_AddressTableViewCell.h"
#import "Consume_MapViewController.h"
#import "Consume_GoodsDetailViewController.h"

@implementation Consume_GD_AddressTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initialize];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
        [self addGestureRecognizer:tap];
    }
    return self;
}

-(void)tapAction{
    Consume_MapViewController *mapVC = [[Consume_MapViewController alloc]init];
    mapVC.destination_LocationCoordinate = CLLocationCoordinate2DMake(34.219873, 108.959122);
    
    Consume_GoodsDetailViewController *detailVC = (Consume_GoodsDetailViewController *)self.nextResponder.nextResponder.nextResponder.nextResponder;
    [detailVC.navigationController pushViewController:mapVC animated:YES];
}
-(void)initialize{
    
    UIView *spaceView = [[UIView alloc]init];
    spaceView.backgroundColor = HexColor(0xF2F6F7);
    [self addSubview:spaceView];
    [spaceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(self);
        make.height.mas_offset(@10);
    }];
    
    _shopNameLabel = [[UILabel alloc]init];
    _shopNameLabel.text = @"小寨张辉oppo手机卖场";
    _shopNameLabel.textColor = HexColor(0x333333);
    _shopNameLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:_shopNameLabel];
    [_shopNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.top.mas_equalTo(spaceView.mas_bottom).offset(15);
        make.right.mas_equalTo(self.mas_right).offset(-15);
        make.height.mas_offset(@15);
    }];
    
    _iconImageView = [[UIImageView alloc]init];
    _iconImageView.image = [UIImage imageNamed:@"con_address"];
    [self addSubview:_iconImageView];
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shopNameLabel);
        make.top.mas_equalTo(self.shopNameLabel.mas_bottom).offset(10);
        make.width.height.mas_offset(@22);
    }];
    
    _addressLabel = [[UILabel alloc]init];
    _addressLabel.text = @"西安市碑林区南稍门中贸广场";
    _addressLabel.textColor = HexColor(0x666666);
    _addressLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:_addressLabel];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImageView.mas_right).offset(5);
        make.centerY.mas_equalTo(self.iconImageView);
        make.right.mas_equalTo(self.mas_right).offset(-100);
    }];
    
    _goBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_goBtn setImage:[UIImage imageNamed:@"con_go"] forState:UIControlStateNormal];
    [self addSubview:_goBtn];
    [_goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.addressLabel);
        make.right.mas_equalTo(self.mas_right).offset(-5);
        make.width.height.mas_offset(@32);
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
